
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_Hans">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Django 1.4.18 release notes &#8212; Django 3.2.6.dev 文档</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="next" title="Django 1.4.17 release notes" href="1.4.17.html" />
    <link rel="prev" title="Django 1.4.19 release notes" href="1.4.19.html" />



 
<script src="../templatebuiltins.js"></script>
<script>
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 3.2.6.dev 文档</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="1.4.19.html" title="Django 1.4.19 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.4.17.html" title="Django 1.4.17 release notes">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="releases-1.4.18">
            
  <div class="section" id="s-django-1-4-18-release-notes">
<span id="django-1-4-18-release-notes"></span><h1>Django 1.4.18 release notes<a class="headerlink" href="#django-1-4-18-release-notes" title="永久链接至标题">¶</a></h1>
<p><em>January 13, 2015</em></p>
<p>Django 1.4.18 fixes several security issues in 1.4.17 as well as a regression
on Python 2.5 in the 1.4.17 release.</p>
<div class="section" id="s-wsgi-header-spoofing-via-underscore-dash-conflation">
<span id="wsgi-header-spoofing-via-underscore-dash-conflation"></span><h2>WSGI header spoofing via underscore/dash conflation<a class="headerlink" href="#wsgi-header-spoofing-via-underscore-dash-conflation" title="永久链接至标题">¶</a></h2>
<p>When HTTP headers are placed into the WSGI environ, they are normalized by
converting to uppercase, converting all dashes to underscores, and prepending
<code class="docutils literal notranslate"><span class="pre">HTTP_</span></code>. For instance, a header <code class="docutils literal notranslate"><span class="pre">X-Auth-User</span></code> would become
<code class="docutils literal notranslate"><span class="pre">HTTP_X_AUTH_USER</span></code> in the WSGI environ (and thus also in Django's
<code class="docutils literal notranslate"><span class="pre">request.META</span></code> dictionary).</p>
<p>Unfortunately, this means that the WSGI environ cannot distinguish between
headers containing dashes and headers containing underscores: <code class="docutils literal notranslate"><span class="pre">X-Auth-User</span></code>
and <code class="docutils literal notranslate"><span class="pre">X-Auth_User</span></code> both become <code class="docutils literal notranslate"><span class="pre">HTTP_X_AUTH_USER</span></code>. This means that if a
header is used in a security-sensitive way (for instance, passing
authentication information along from a front-end proxy), even if the proxy
carefully strips any incoming value for <code class="docutils literal notranslate"><span class="pre">X-Auth-User</span></code>, an attacker may be
able to provide an <code class="docutils literal notranslate"><span class="pre">X-Auth_User</span></code> header (with underscore) and bypass this
protection.</p>
<p>In order to prevent such attacks, both Nginx and Apache 2.4+ strip all headers
containing underscores from incoming requests by default. Django's built-in
development server now does the same. Django's development server is not
recommended for production use, but matching the behavior of common production
servers reduces the surface area for behavior changes during deployment.</p>
</div>
<div class="section" id="s-mitigated-possible-xss-attack-via-user-supplied-redirect-urls">
<span id="mitigated-possible-xss-attack-via-user-supplied-redirect-urls"></span><h2>Mitigated possible XSS attack via user-supplied redirect URLs<a class="headerlink" href="#mitigated-possible-xss-attack-via-user-supplied-redirect-urls" title="永久链接至标题">¶</a></h2>
<p>Django relies on user input in some cases (e.g.
<code class="docutils literal notranslate"><span class="pre">django.contrib.auth.views.login()</span></code> and <a class="reference internal" href="../topics/i18n/index.html"><span class="doc">i18n</span></a>)
to redirect the user to an &quot;on success&quot; URL. The security checks for these
redirects (namely <code class="docutils literal notranslate"><span class="pre">django.utils.http.is_safe_url()</span></code>) didn't strip leading
whitespace on the tested URL and as such considered URLs like
<code class="docutils literal notranslate"><span class="pre">\njavascript:...</span></code> safe. If a developer relied on <code class="docutils literal notranslate"><span class="pre">is_safe_url()</span></code> to
provide safe redirect targets and put such a URL into a link, they could suffer
from a XSS attack. This bug doesn't affect Django currently, since we only put
this URL into the <code class="docutils literal notranslate"><span class="pre">Location</span></code> response header and browsers seem to ignore
JavaScript there.</p>
</div>
<div class="section" id="s-denial-of-service-attack-against-django-views-static-serve">
<span id="denial-of-service-attack-against-django-views-static-serve"></span><h2>Denial-of-service attack against <code class="docutils literal notranslate"><span class="pre">django.views.static.serve</span></code><a class="headerlink" href="#denial-of-service-attack-against-django-views-static-serve" title="永久链接至标题">¶</a></h2>
<p>In older versions of Django, the <a class="reference internal" href="../ref/views.html#django.views.static.serve" title="django.views.static.serve"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.static.serve()</span></code></a> view read
the files it served one line at a time. Therefore, a big file with no newlines
would result in memory usage equal to the size of that file. An attacker could
exploit this and launch a denial-of-service attack by simultaneously requesting
many large files. This view now reads the file in chunks to prevent large
memory usage.</p>
<p>Note, however, that this view has always carried a warning that it is not
hardened for production use and should be used only as a development aid. Now
may be a good time to audit your project and serve your files in production
using a real front-end web server if you are not doing so.</p>
</div>
<div class="section" id="s-bugfixes">
<span id="bugfixes"></span><h2>Bugfixes<a class="headerlink" href="#bugfixes" title="永久链接至标题">¶</a></h2>
<ul class="simple">
<li>To maintain compatibility with Python 2.5, Django's vendored version of six,
<code class="docutils literal notranslate"><span class="pre">django.utils.six</span></code>, has been downgraded to 1.8.0 which is the last
version to support Python 2.5.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Django 1.4.18 release notes</a><ul>
<li><a class="reference internal" href="#wsgi-header-spoofing-via-underscore-dash-conflation">WSGI header spoofing via underscore/dash conflation</a></li>
<li><a class="reference internal" href="#mitigated-possible-xss-attack-via-user-supplied-redirect-urls">Mitigated possible XSS attack via user-supplied redirect URLs</a></li>
<li><a class="reference internal" href="#denial-of-service-attack-against-django-views-static-serve">Denial-of-service attack against <code class="docutils literal notranslate"><span class="pre">django.views.static.serve</span></code></a></li>
<li><a class="reference internal" href="#bugfixes">Bugfixes</a></li>
</ul>
</li>
</ul>

  <h4>上一个主题</h4>
  <p class="topless"><a href="1.4.19.html"
                        title="上一章">Django 1.4.19 release notes</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="1.4.17.html"
                        title="下一章">Django 1.4.17 release notes</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/releases/1.4.18.txt"
            rel="nofollow">显示源代码</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>快速搜索</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="转向" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">7月 23, 2021</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="1.4.19.html" title="Django 1.4.19 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.4.17.html" title="Django 1.4.17 release notes">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>